package cn.edu.service.impl;

import cn.edu.dao.lead_OpusDao;
import cn.edu.dao.lead_PatentDao;
import cn.edu.domain.PageBean;
import cn.edu.domain.opus;
import cn.edu.domain.patent;
import cn.edu.service.lead_OpusService;
import cn.edu.service.lead_PatentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Davey chan
 */
@Service
public  class lead_PatentServiceImpl implements lead_PatentService {
  @Autowired
private lead_PatentDao patentDao;
    @Override
    public PageBean<patent> selectByPageAndcondition(int currentPage, int pageSize, patent t) {
        int begin=(currentPage-1)*pageSize;
//        计算查询的条目数
        int size =pageSize;
        String patentName = t.getPatentName();
        if(patentName !=null && patentName.length()>0){
            t.setPatentName("%"+patentName+"%");
        }
        String patenttype= t.getPatenttype();
        if(patenttype !=null &&patenttype.length()>0){
            t.setPatenttype("%"+patenttype+"%");

        }
        String academy = t.getAcademyName();
        if(academy !=null && academy.length()>0){
            t.setAcademyName("%"+academy+"%");

        }
        List<patent> rows = patentDao.selectBypage(begin, size,t);
//        查询总记录数
        int totalCount =patentDao.selectTotalCount(t);
//封装pageBean
        PageBean<patent> pageBean=new PageBean<>();
        pageBean.setRows(rows);
        pageBean.setTotalCount(totalCount);
        return pageBean;
    }


}
